var express = require('express')
var app = express()
var router = require('./router.js')
var bodyParser = require('body-parser');
var path = require('path')

app.use('/public', express.static(path.join(__dirname, 'public')))
// app.use('/public',express.static(path.join(__dirname, './public')))
// app.use('/public',express.static('public'))
// app.use('/static', express.static('public'));

app.use(bodyParser.json()) 
app.use(bodyParser.urlencoded({ extended: true })) 



app.all("*",(req,res,next)=>{
	res.header('Access-Control-Allow-Origin','*');
	res.header('Access-Control-Allow-Headers','Content-Type');
	res.header('Access-Control-Allow-Methods','*');
	res.header('AContent-Type','application/json;charset=utf-8');
	next();
})

/* app.all('*', function(req, res, next) {
 
res.header("Access-Control-Allow-Origin", "*");//项目上线后改成页面的地址
 
res.header("Access-Control-Allow-Headers", "X-Requested-With,Content-Type");
 
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
 
next();
 
}); */
 
app.use(router)


app.listen(8080,function(){
	console.log('service is running...')
})

